package com.gwt.implementation;


import com.game.interfacesForGame.Color;
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.canvas.dom.client.CssColor;


public class Screen implements com.game.interfacesForImplementer.Canvas{
	public Canvas canvas;
	
	public int getHeight() {
		return canvas.getCoordinateSpaceHeight();
	}

	public int getWidth() {
		return canvas.getCoordinateSpaceWidth();
	}

	public void rectangle(int x, int y, int width, int height, Color color) {
		Context2d context = canvas.getContext2d();
        CssColor c = CssColor.make("rgba(" + color.getRed() + ", " + color.getGreen() + "," + color.getBlue() + ", 255)");
        context.setFillStyle(c);
        context.fillRect(x,y,width,height);
        context.fill();
	}

	public void line(int x1, int y1, int x2, int y2, Color color) {
		Context2d context = canvas.getContext2d();
        CssColor c = CssColor.make("rgba(" + color.getRed() + ", " + color.getGreen() + "," + color.getBlue() + ", 255)");
        context.setStrokeStyle(c);
        context.setLineCap("square");
        context.setLineWidth(1);
        context.setLineJoin("bevel");
        context.beginPath();
        context.moveTo(x1, y1);
        context.lineTo(x2, y2);
        context.stroke();
	}

	public void circle(int x, int y, int radius, Color color) {
		Context2d context = canvas.getContext2d();
        CssColor c = CssColor.make("rgba(" + color.getRed() + ", " + color.getGreen() + "," + color.getBlue() + ", 255)");
        context.setStrokeStyle(c);
        context.beginPath();
        context.arc(x, y, radius, 0, Math.PI * 2.0);
        context.closePath();
        context.stroke();
	}

}
